from __future__ import annotations
from dataclasses import dataclass, field
import dotenv
import os

dotenv.load_dotenv()  # 读取 .env 文件

@dataclass
class GlobalConfig:
    server_host: str = field(default="0.0.0.0")
    exposed_host: str = field(default_factory=lambda: os.getenv("EXPOSED_ADDR", "127.0.0.1"))
    udp_port: int = field(default_factory=lambda: int(os.getenv("UDP_PORT", "8888")))
    ota_port: int = field(default_factory=lambda: int(os.getenv("OTA_PORT", "8888")))
    mqtt_port: int = field(default_factory=lambda: int(os.getenv("MQTT_PORT", "1883")))


# 全局配置实例
CONFIG = GlobalConfig()
